
#ifndef _APP_KEY_H
#define _APP_KEY_H

#ifdef __cplusplus
extern "C" {
#endif

#define KEY_STATE0       0
#define KEY_STATE1       1
#define KEY_STATE2       2
#define KEY_STATE3       3

#define KEY_SHORTPRESS              10//短按持续时间
#define KEY_LONGPRESS               100//长按持续时间
#define KEY_LONGPRESSCONTINU        10//长按连发持续时间

#define KEY_NOPRESSVAL          0
#define KEY_SHORTPRESSVAL       1
#define KEY_LONGPRESSVAL        2
#define KEY_RELEASEVAL          3

#define KEY_NUM                 21

#define KEY_READ_IDX            0
#define KEY_WRITE_IDX           17
#define KEY_UP_IDX              8
#define KEY_DOWN_IDX            18
#define KEY_LEFT_IDX            4 
#define KEY_RIGHT_IDX           16
#define KEY_OK_IDX              12 
#define KEY_POWER_IDX           20
#define KEY_0_IDX               19
#define KEY_1_IDX               15
#define KEY_2_IDX               14
#define KEY_3_IDX               13
#define KEY_4_IDX               11
#define KEY_5_IDX               10
#define KEY_6_IDX               9
#define KEY_7_IDX               7
#define KEY_8_IDX               6  
#define KEY_9_IDX               5



typedef struct
{
    uint8_t keystate;//按键状态           
    uint8_t keyvalstate;//按键状态值
    uint8_t keydebugcnt;//按键消抖值
    uint8_t  keyval;//按键值
    uint8_t keylongpresscontinu;//是否支持连续长按
    uint8_t keyshortpress;
    uint8_t keylongpress;
} KEY_t;


#ifdef __cplusplus
}
#endif
void app_key_init(KEY_t *key);
void app_key_scan(KEY_t *key);
void app_key_process(KEY_t *key);
#endif /* __ZB32L03x_STARTERKIT_H */


